<script setup lang="ts">
const route=useRoute();
const lookup=useLookupStore();
const current=ref<any>({})
const domain=route.params.domain as string;
const getWhois=async (domain:string)=>{
  if(!domain) return ElMessage.error('请输入域名');
  if(lookup.whois[domain]){
    current.value=lookup.whois[domain];
    return;
  }
  const {data,refresh}=await useServerGet('/west/whois',{domain})
  if(data?.value.code===200){
    data.value.data.domain=domain;
    current.value=data.value.data;
    lookup.setWhois(current.value);
  }
}
getWhois(domain);
</script>

<template>
<div>
  <div class="w-[1200px] mx-auto">
    <el-card class="mt-4 h-[630px] overflow-auto">
    <div class="text-center text-base font-600">域名{{domain}} whois 信息</div>
      <el-form class="ml-40" label-width="100" label-suffix="：">
        <el-form-item label="注册时间">
          {{current.regdate}}
        </el-form-item>
        <el-form-item label="到期时间">
          {{current.expdate}}
        </el-form-item>
        <el-form-item label="更新时间">
          {{current.upddate}}
        </el-form-item>
        <el-form-item label="注册商">
          {{current.registrar}}
        </el-form-item>
        <el-form-item label="域名服务器">
          {{current.nameserver}}
        </el-form-item>
        <el-form-item label="业务服务器">
          {{current.bizserver?current.bizserver:'无'}}
        </el-form-item>
        <el-form-item label="状态">
          <div  v-for="item in current.status?.split(',')">{{item}}</div>
        </el-form-item>
        <el-form-item label="详细信息">
          <div v-html="current.body"></div>
        </el-form-item>

      </el-form>
    </el-card>
  </div>
</div>
</template>

<style scoped lang="scss">

</style>